<%--
 *  File:    UploadSummaryTempMonthplanDetail.jsp	
 *  @Author: yuelongma 
 *  Date:    2012/09/11
 *
 *  Copyright (C) 2000 - 2008 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  //init param
  String privilegeCode = "FP1010,FP1050,FP1090,FP1140,FP1180,FP1220";
  String strTableName = "";
  String strModuleName = "COM";
  String contextPath = request.getContextPath();
  
%>
<%@ include file="/inc/CommonHeader.inc" %>
<%@ include file="/inc/OvalLocationDefault.inc" %>
<%@ include file="/rpt/ReportURL.inc"%>

<html>
<head>
<title>UploadSummaryDoctor</title>
<PageFlow:CheckPageFlow pageName="p_uploadtempmonthplandetail"/>
<%@ include file="/inc/CatchError.inc" %>
<%@ include file="/inc/SumDiv.inc" %>
<%
Vector totalsummary = (Vector)pageContext.getAttribute("totalsummary");
Vector provector = (Vector)pageContext.getAttribute("provector");
if(totalsummary == null) totalsummary = new Vector();
if(provector == null) provector = new Vector();
String allflag = (String)pageContext.getAttribute("allflag");
HashMap UserInfo = (HashMap)session.getAttribute("userinfo");


if(UserInfo == null) UserInfo = new HashMap();

HashMap prohash=new HashMap();
for(int i=0;i<provector.size();i++){
	  prohash.put(((HashMap)provector.get(i)).get("numcode"),((HashMap)provector.get(i)).get("productgroupname"));
}

String subjectcode = (String)pageContext.getAttribute("subjectcode");

String level = pageContext.getAttribute("planlevel").toString();

int planlevel = 0;
if(level != null){

planlevel =Integer.parseInt(level);
}



%>
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/cn/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/SummaryDivision.js"></script>

<script language="JavaScript">
<%--  put your custom script here   --%>
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(cform,actionvalue,orderbyname);
  if(!editform) return;
  editform.action = "UploadSummaryTempMonthplanDetail.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();
}

function page_check()
{
    cform.actionname.value = "check";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}

function page_confirm(){
    <%--if(nullChecked(document.cform.uploadorgids))
        {
          alert("<%= message.getMessageDesc("PLEASE_SELECT") %>");
          return;
        }--%>
	cform.actionname.value = "confirm";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}
function page_refuse(){
    <%--if(nullChecked(document.cform.uploadorgids))
        {
          alert("<%= message.getMessageDesc("PLEASE_SELECT") %>");
          return;
        }--%>
	cform.actionname.value = "refuse";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}
function page_agree(){
    <%--if(nullChecked(document.cform.uploadorgids))
        {
          alert("<%= message.getMessageDesc("PLEASE_SELECT") %>");
          return;
        }--%>
	cform.actionname.value = "agree";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}
function page_approval(){
    <%--if(nullChecked(document.cform.uploadorgids))
        {
          alert("<%= message.getMessageDesc("PLEASE_SELECT") %>");
          return;
        }--%>
	cform.actionname.value = "approval";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}

function page_giveup(){
	var flag1 = confirm("<%= message.getMessageDesc("SURE_GIVE_UP")%>");
	if(!flag1){
		return;
	}
	cform.actionname.value = "giveup";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}	

function page_operate(operand)
{
	var file = cform.file.value;
	if(file == null || file == "")return;
    cform.encoding="multipart/form-data";
    cform.code.value = file.substring(file.lastIndexOf("\\")+1,file.indexOf("_"));
    cform.csvfile.value = file.substring(0,file.lastIndexOf("."))+".csv";
	if(<%=planlevel%> == 1){
		cform.uploadiflag.value = "monthplan1";
	}else if(<%=planlevel%> == 2){
		cform.uploadiflag.value = "monthplan2";
	}else if(<%=planlevel%> == 3){
		cform.uploadiflag.value = "monthplan3";
	}else if(<%=planlevel%> == 4){
		cform.uploadiflag.value = "monthplan4";
	}else if(<%=planlevel%> == 5){
		cform.uploadiflag.value = "monthplan5";
	}else if(<%=planlevel%> == 6){
		cform.uploadiflag.value = "monthplan6";
	}
    
    cform.actionname.value = "loadfile";
    cform.target = "_self";
   	cform.submit();
	  
}
function page_print(){
	var employeeid=document.cform.userid.value;

	if(<%=planlevel%> == 2){
		
		 var url1 = "<%=reportURL%>/servlet/ExcecuteReport/regionyearplanerrormessage.sox?__format=xlsx&__folder=/ovalreport&e1="+employeeid ;
			var strstatus="height=768, width=1024,top=0,left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no";
		    popwindow = window.open(url1, "n1window", strstatus);	
		    
		}
	else if (<%=planlevel%> == 1){

		 var url1 = "<%=reportURL%>/servlet/ExcecuteReport/deptyearplanerrormessage.sox?__format=xlsx&__folder=/ovalreport&e1="+employeeid ;
			var strstatus="height=768, width=1024,top=0,left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no";
		    popwindow = window.open(url1, "n1window", strstatus);	
		    
		
		}
		
	else if (<%=planlevel%> == 3){

		var url1 = "<%=reportURL%>/servlet/ExcecuteReport/areayearplanerrormessage.sox?__format=xlsx&__folder=/ovalreport&e1="+employeeid ;
		var strstatus="height=768, width=1024,top=0,left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no";
	    popwindow = window.open(url1, "n1window", strstatus);	
	    
	}
	else if (<%=planlevel%> == 4){

	    var url1 = "<%=reportURL%>/servlet/ExcecuteReport/salesrepyearplanerrormessage.sox?__format=xlsx&__folder=/ovalreport&e1="+employeeid ;
		var strstatus="height=768, width=1024,top=0,left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no";
	    popwindow = window.open(url1, "n1window", strstatus);	
	    
	}
	else if (<%=planlevel%> == 5){

	    var url1 = "<%=reportURL%>/servlet/ExcecuteReport/customeryearplanerrormessage.sox?__format=xlsx&__folder=/ovalreport&e1="+employeeid ;
		var strstatus="height=768, width=1024,top=0,left=0,toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no";
	    popwindow = window.open(url1, "n1window", strstatus);	
	}
	
	else if(<%=planlevel%> == 6){
		

		}


}

function page_confirm1(){
	 /*   if(nullChecked(document.cform.uploadorgids))
	        {
	          alert("<%= message.getMessageDesc("PLEASE_SELECT") %>");
	          return;
	        }*/
		cform.actionname.value = "confirm1";
	    cform.target = "_self";
	    isRunning = true;
	    cform.submit();
	}
function page_submit(){
	//cform.pagename.value="p_temporg112";
	cform.actionname.value = "submit";
    cform.target = "_self";
    isRunning = true;
    cform.submit();
}
</script>
</head>

<body style="overflow: auto;">
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher">
    <input type="hidden" name="pagename" value="p_uploadtempmonthplandetail">
    <input type="hidden" name="actionname">
    <input type="hidden" name="name">
    <input type="hidden" name="type">
    <custom:hidden property="category"/>
    <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">
    
    <%if(planlevel==2){ %>
    <input type="hidden" name="sheetname" value="regionmonthplan">
    <input type="hidden" name="flag" value="regionmonthplan">
    <%}else if(planlevel==1){  %>
    <input type="hidden" name="sheetname" value="deptmonthplan">
    <input type="hidden" name="flag" value="deptmonthplan">
    <%}else if(planlevel==3){  %>
    <input type="hidden" name="sheetname" value="areamonthplan">
    <input type="hidden" name="flag" value="areamonthplan">
        <%}else if(planlevel==5){  %>
    <input type="hidden" name="sheetname" value="customermonthplan">
    <input type="hidden" name="flag" value="customermonthplan">
        <%}else if(planlevel==4){  %>
    <input type="hidden" name="sheetname" value="salesrepmonthplan">
    <input type="hidden" name="flag" value="salesrepmonthplan">
       <%}else if(planlevel==6){  %>
    <input type="hidden" name="sheetname" value="doctormonthplan">
    <input type="hidden" name="flag" value="doctormonthplan">
    <%} %>
    <input type="hidden" name="subjectcode" value="822">
    
    <input type="hidden" name="planlevel" value="<%=planlevel %>" >

    <custom:hidden property="planlevel"></custom:hidden>
    
    <input type="hidden" name="code" />
  	<input type="hidden" name="codeinsheet" value = "Y"/>
  	<input type="hidden" name="csvfile" />
	<input type="hidden" name="uploadiflag"/>
	

    <input type="hidden" name="__header__Content-disposition" id="outname" value="attachment;filename=DistributorMasterData.xls" />
	<custom:hidden scope="session" name="userinfo" property="userid"></custom:hidden>

<%--  page location   --%>
    <%@ include file="/inc/PageLocation.inc" %>

    <table width="100%" cellspacing="0" border="0" cellpadding="0">
      <tr>
<%--  search criteria  --%>
      </tr>
      <tr>
        <td>
          <table width="100%" border="0" cellspacing="0">
             <tr>
			  <td> 
			  	<%= label.getLabelName("L_Path") %><%= label.getLabelName("L_Colon") %><input type="file" name="file" size="30" >
			    &nbsp;&nbsp;&nbsp;&nbsp;<a onclick="page_operate('upload')"><custom:button type="1" label="L_Finish" imgsrc="finish.gif" border="0" style="width:60"/></a>
			    
			  </td>
			 </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td>
<div style="overflow:auto;width:1230;height:400">
          <table width="3000"  border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
            <tr class="deepblue-left">            
              <td class="title_center" ><%= label.getLabelName("L_PlanCode") %></td>
              <%--
              <%if(planlevel==2){ %>
              <td class="title_center" ><%= label.getLabelName("L_CcountryWide") %></td>
              <td class="title_center" ><%= label.getLabelName("L_Provicetdr") %></td>
              
				 <% }else if(planlevel==1){%>
			  <td class="title_center" ><%= label.getLabelName("L_CountryRegion") %></td>
              <td class="title_center" ><%= label.getLabelName("L_Department") %></td>
               <% }else if(planlevel==3){%>
               <td class="title_center" ><%= label.getLabelName("L_CcountryWide") %></td>
              <td class="title_center" ><%= label.getLabelName("L_RegionOffice") %></td>
               <% }else if(planlevel==4){%>
              <td class="title_center" ><%= label.getLabelName("L_DeptArea") %></td>
              <td class="title_center" ><%= label.getLabelName("L_Person") %></td>
                <% }else if(planlevel==5){%>
             <td class="title_center" ><%= label.getLabelName("L_PersonArea") %></td>   
             <td class="title_center" ><%= label.getLabelName("L_Customer") %></td>
                 <% }else if(planlevel==6){%>
              <td class="title_center" ><%= label.getLabelName("L_Doctor") %></td>
              <%} %> 
              --%> 
              <%if(planlevel==5){  %>
              <td class="title_center" ><%= label.getLabelName("L_Employee")+label.getLabelName("L_Code") %></td>
              <td class="title_center" ><%= label.getLabelName("L_Employee")+label.getLabelName("L_Name") %></td>
              <td class="title_center" ><%= label.getLabelName("L_RegionOffice")+label.getLabelName("L_Code") %></td>
              <td class="title_center" ><%= label.getLabelName("L_RegionOffice")+label.getLabelName("L_Name") %></td>
              <%}else{  %>
              <td class="title_center" ><%= label.getLabelName("L_last")+label.getLabelName("L_Code") %></td>
              <td class="title_center" ><%= label.getLabelName("L_last")+label.getLabelName("L_Name") %></td>
              <%} %> 
              <td class="title_center" ><%= label.getLabelName("L_Code") %></td>
              <td class="title_center" ><%= label.getLabelName("L_Name") %></td>
              
              <td class="title_center" ><%= label.getLabelName("L_ProductOrProductGroup") + label.getLabelName("L_Code")%></td>
              <td class="title_center" ><%= label.getLabelName("L_ProductOrProductGroup") + label.getLabelName("L_Name")%></td>
              <td class="title_center" ><%= label.getLabelName("L_OneMonth") %></td>
              <td class="title_center" ><%= label.getLabelName("L_TwoMonth") %></td>
              
              
              <td class="title_center" ><%= label.getLabelName("L_ThreeMonth") %></td>
              <td class="title_center" ><%= label.getLabelName("L_FourMonth") %></td>
              <td class="title_center" ><%= label.getLabelName("L_FiveMonth") %></td>
              <td class="title_center" ><%= label.getLabelName("L_SixMonth") %></td>
              <td class="title_center" ><%= label.getLabelName("L_SevenMonth") %></td>              
              <td class="title_center" ><%= label.getLabelName("L_EightMonth") %></td>
              
			  <td class="title_center" ><%= label.getLabelName("L_NineMonth") %></td>
			  <td class="title_center" ><%= label.getLabelName("L_TenMonth") %></td>
			  <td class="title_center" ><%= label.getLabelName("L_ElevenMonth") %></td>
			  <td class="title_center" ><%= label.getLabelName("L_TwelveMonth") %></td>
              <td class="title_center"  width="8%"><%= label.getLabelName("L_ErrorMsg") %> </td>
             
            </tr>
            
<%
	int i=0;
	String strClassType="";
	int checkflag = -1;
%>
            <%--  the old detail lines  --%>
 <span id="olddetail" >
            <logic:iterate id="onerow" collection="<%= totalsummary %>" indexId="idx" scope="page">
<%
	if(i%2 == 1)
	  {
	    strClassType = "td-listrom";
	  }else{                    
	    strClassType = "none";
	  }
	  i++;
	  
	  HashMap row = (HashMap)pageContext.getAttribute("onerow");
	if(row.get("errormassage") != null){
		strClassType = "need";
		
	}
	//out.print(i+":"+row.get("status") );
	if(row.get("status") != null){
	checkflag =	((Integer)row.get("status")).intValue();
	}
%>
            <tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=strClassType%>'" class="<%=strClassType%>">
              <td><custom:write property="monthplancode" name="onerow" nbsp="true"/></td>
              <td><custom:write property="lastgradecode" name="onerow" nbsp="true"/></td>
              <td><custom:write property="lastgrade" name="onerow" nbsp="true"/></td>
              <%if(planlevel==5){  %>
               <td><custom:write property="areacode" name="onerow" nbsp="true"/></td>
               <td><custom:write property="areaname" name="onerow" nbsp="true"/></td>
              <%} %>
              <td><custom:write property="currentgradecode" name="onerow" nbsp="true"/></td>
              <td><custom:write property="currentgrade" name="onerow" nbsp="true"/></td>
              <td><custom:write property="prodcode" name="onerow" nbsp="true"/></td>
              <td><custom:write property="prodname" name="onerow" nbsp="true"/></td>
              <td><custom:write property="jan" name="onerow" nbsp="true"/></td>
              
              <td><custom:write property="feb" name="onerow" nbsp="true"/></td>
              <td><custom:write property="thu" name="onerow" nbsp="true"/></td>
              <td><custom:write property="mar" name="onerow" nbsp="true"/></td>
              <td><custom:write property="may" name="onerow" nbsp="true"/></td>
              <td><custom:write property="june" name="onerow" nbsp="true"/></td>              
              <td><custom:write property="july" name="onerow" nbsp="true"/></td>              
              <td><custom:write property="aug" name="onerow" nbsp="true"/></td>
              
              <td><custom:write property="sep" name="onerow"  nbsp="true"/></td>
              <td><custom:write property="oct" name="onerow"  nbsp="true"/></td>
              <td><custom:write property="nov" name="onerow"  nbsp="true"/></td>
              <td><custom:write property="dec" name="onerow"  nbsp="true"/></td>
                 
              
              <td><custom:write property="errormassage" name="onerow" nbsp="true"/></td>
            </tr>

            </logic:iterate>
</span>
			<tr>
				<td colspan="68" align="left"><%= label.getLabelName("L_TotalData") + label.getLabelName("L_Colon") %><custom:write property="count" name="count" nbsp="true"/></td>
			</tr>

            <%@ include file="/inc/SummaryActionUP.inc" %>
          </table>
</div>
          <table width="100%" cellspacing="0" cellpadding="0">
            <tr><td class="summary_top"></td></tr>
            <tr>
              <td class="td_center">
		      		<%if (totalsummary.size() > 0){ 
					if(checkflag == 10 ){%>
				                <a onclick="page_check();"><custom:button type="1" label="L_CheckContent" imgsrc="new.gif" border="0" style="width:60"/></a>
				<%}else if (10 != checkflag){ %>                
				                <a onclick="javascript:page_print();"><custom:button type="1" label="L_Execcd" imgsrc="new.gif" border="0" style="width:60"/></a>				           
				                <a onclick="javascript:page_confirm();"><custom:button type="1" label="L_Submit1" imgsrc="new.gif" border="0" style="width:60"/></a>
				                <a onclick="javascript:page_giveup();"><custom:button type="1" label="L_GiveUp" imgsrc="new.gif" border="0" style="width:60"/></a> 
<!--				                <a onclick="javascript:page_confirm1();"><custom:button type="1" label="L_Submit1" imgsrc="new.gif" border="0" style="width:60"/></a> 
				              
				                <a onclick="javascript:page_submit();"><custom:button type="1" label="L_Submit_batch" imgsrc="new.gif" border="0" style="width:60" /></a>
				                  --><%}} %>
				<%--}else if(("N").equals(checkflag)){ %>
				                <a onclick="javascript:();"><custom:button type="1" label="L_Execcd" imgsrc="new.gif" border="0" style="width:60"/></a>				           
				                
				                <a onclick="javascript:page_giveup();"><custom:button type="1" label="L_GiveUp" imgsrc="new.gif" border="0" style="width:60"/></a>									                
				<%}}--%>  
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
</form>
</body>
</html>